import {
    legacy_createStore as createStore
} from 'redux'
const state = {
    collapsed: false,
    open: false,
    types: ""
}
// 定义reducer
const reducer = (newState = state, action) => {
    // 进行action规则的操作

    const {
        type,
        data,
    } = action
    // console.log(data,newState);
    //数据改变
    switch (type) {
        case "collapsed":
            newState = {
                ...newState,
                collapsed: !newState.collapsed
            }
            break;
        case "open":
            newState = {
                ...newState,
                open: data
            }
            break;
        case "types":
            newState = {
                ...newState,
                types: data
            }
            break;
    }
    // 得到新的state
    return newState
}

// 根据reducer创建仓库
const store = createStore(reducer)

// 导出仓库
export default store